home *** CD-ROM | disk | FTP | other *** search
- property awardsList, roadNameList, firstAwardChannel, roadNameEntry, maxRoadNames, entryX, entryY, firstRoadSlotChan, firstRoadNameChan, trailsSprite, firstLetterBmap, maxCharWidth, maxWidth, maxChars, cursor, cursorCounter, cursorSpeed, onOrOff, roadName, roadOffsets, awardsDataString, dataCounter, roadBitmap, roadBitmapChan, roadSlotVdistance, firstRoadSlotLocV, entrySlot
- global gActorList, gHiddenActorList, gUserObject, gMenuObject, gLevelObject, gTruckObject, gSimObject
-
- on birth me
- set firstAwardChannel to 9
- set awardsList to ["VTL": 0, "HardHat": 0, "JobSite": 0, "MakeAscene": 0]
- set roadNameList to []
- set roadName to []
- set roadOffsets to [0]
- set roadNameEntry to 0
- set firstRoadSlotChan to 2
- set firstRoadNameChan to 15
- set maxRoadNames to 6
- set firstRoadSlotLocV to 111
- set roadSlotVdistance to 51
- set entryX to 0
- set entryY to 0
- set entrySlot to 0
- set trailsSprite to 13
- set maxCharWidth to 18
- set maxWidth to 143
- set maxChars to 11
- set cursorCounter to 1
- set cursorSpeed to 8
- set onOrOff to 0
- set firstLetterBmap to the number of cast "a2.lower"
- set cursor to firstLetterBmap + 53
- set roadBitmap to the number of cast "roadBitmap"
- set roadBitmapChan to 8
- return me
- end
-
- on update me
- if roadNameEntry and (count(roadName) = 0) then
- blinkQuestion(me)
- end if
- end
-
- on predraw me
- repeat with x = 1 to count(awardsList)
- set boolean to getAt(awardsList, x)
- if boolean = 0 then
- set channel to firstAwardChannel + x - 1
- puppetSprite(channel, 1)
- removeSprite(channel)
- end if
- end repeat
- if roadNameEntry = 1 then
- set the locH of sprite roadBitmapChan to 60
- set locV to firstRoadSlotLocV + ((entrySlot - 1) * roadSlotVdistance)
- set the locV of sprite roadBitmapChan to locV
- set the castNum of sprite roadBitmapChan to roadBitmap
- puppetSprite(roadBitmapChan, 1)
- end if
- end
-
- on cheat me
- setProp(awardsList, "VTL", 1)
- setProp(awardsList, "HardHat", 1)
- setProp(awardsList, "JobSite", 1)
- setProp(awardsList, "MakeAscene", 1)
- end
-
- on setup me
- clearAllActors()
- add(gActorList, me)
- repeat with x = 1 to count(awardsList)
- set channel to firstAwardChannel + x - 1
- puppetSprite(channel, 1)
- end repeat
- puppetSprite(roadBitmapChan, 1)
- postRoadNames(me)
- if roadNameEntry = 1 then
- repeat with x = 1 to maxChars
- set channel to firstRoadNameChan + x - 1
- puppetSprite(channel, 1)
- end repeat
- set newRoadSlot to firstRoadSlotChan + entrySlot - 1
- set entryX to the left of sprite newRoadSlot + 7
- set entryY to the locV of sprite newRoadSlot
- end if
- if roadNameEntry then
- add(gActorList, birth(script "Rollover Anim Button Class", "returnToSim( gAwardsObject, me )", 27, 27, 5, "B14VO01", "B14RO01"))
- else
- add(gActorList, birth(script "Rollover Anim Button Class", "goMenu( gAwardsObject, me )", 27, 27, 5, "RCA-07VO01", "RCA-07RO01"))
- end if
- add(gActorList, birth(script "Rollover Anim Button Class", "help( gAwardsObject, me )", 28, 28, 11, EMPTY, "RCA-05RO02"))
- end
-
- on postRoadNames me
- repeat with x = 1 to count(roadNameList)
- if not (roadNameEntry and (x = entrySlot)) then
- set slotSprite to firstRoadSlotChan + x - 1
- set savedNameData to getAt(roadNameList, x)
- set savedName to getAt(savedNameData, 1)
- set savedOffsets to getAt(savedNameData, 2)
- set slotCenter to the locH of sprite slotSprite
- set lastBmap to firstLetterBmap + getAt(savedName, count(savedName)) - 1
- set lastCharWidth to getKernValue(lastBmap)
- set savedNameWidth to getLast(savedOffsets) + 62
- set locH to slotCenter - integer(savedNameWidth / 2)
- set the locV of sprite trailsSprite to the locV of sprite slotSprite
- repeat with letterIndex = 1 to count(savedName)
- set the castNum of sprite trailsSprite to firstLetterBmap + getAt(savedName, letterIndex) - 1
- set the locH of sprite trailsSprite to locH + getAt(savedOffsets, letterIndex)
- updateStage()
- end repeat
- set the locH of sprite trailsSprite to the locH of sprite trailsSprite + lastCharWidth + 7
- set the castNum of sprite trailsSprite to roadBitmap
- updateStage()
- end if
- end repeat
- removeSprite(trailsSprite)
- end
-
- on addRoadName me
- if roadNameEntry then
- if count(roadName) > 0 then
- setAt(roadNameList, entrySlot, [roadName, roadOffsets])
- else
- setAt(roadNameList, entrySlot, [the userName of gUserObject, the letterHoffsets of gUserObject])
- end if
- set roadName to []
- set roadOffsets to [0]
- set roadNameEntry to 0
- end if
- end
-
- on simAward me
- set entrySlot to entrySlot + 1
- if entrySlot > maxRoadNames then
- set entrySlot to 1
- end if
- set roadNameEntry to 1
- end
-
- on giveAward me, awardName
- setProp(awardsList, awardName, 1)
- end
-
- on enterLetter me, letterNum
- if ((getLast(roadOffsets) + maxCharWidth) <= maxWidth) and (count(roadName) < maxChars) then
- set channel to firstRoadNameChan + count(roadName)
- if count(roadName) = 0 then
- if letterNum = 53 then
- exit
- end if
- set letterNum to letterNum + 26
- end if
- set whichCast to firstLetterBmap + letterNum - 1
- set the castNum of sprite channel to whichCast
- set currentOffset to getLast(roadOffsets)
- set the locH of sprite channel to entryX + currentOffset
- set the locV of sprite channel to entryY
- set letterWidth to getKernValue(whichCast)
- set latestOffset to currentOffset + letterWidth
- add(roadOffsets, latestOffset)
- add(roadName, letterNum)
- set the locH of sprite roadBitmapChan to entryX + latestOffset + 7
- set the locV of sprite roadBitmapChan to entryY
- updateStage()
- else
- beep(1)
- end if
- end
-
- on eraseLetter me
- if count(roadName) > 0 then
- deleteAt(roadName, count(roadName))
- deleteAt(roadOffsets, count(roadOffsets))
- set the locH of sprite (firstRoadNameChan + count(roadName)) to 1000
- if count(roadName) > 0 then
- set the locH of sprite roadBitmapChan to entryX + getLast(roadOffsets) + 4
- else
- set the locH of sprite roadBitmapChan to 60
- end if
- updateStage()
- else
- beep(1)
- end if
- end
-
- on blinkQuestion me
- if cursorCounter > cursorSpeed then
- if onOrOff = 0 then
- set the locH of sprite firstRoadNameChan to entryX
- set the locV of sprite firstRoadNameChan to entryY
- set the castNum of sprite firstRoadNameChan to cursor
- set onOrOff to 1
- else
- set the locH of sprite firstRoadNameChan to 1000
- set onOrOff to 0
- end if
- set cursorCounter to 0
- else
- set cursorCounter to cursorCounter + 1
- end if
- end
-
- on keyHandler me
- set whichKey to the key
- set ascii to charToNum(whichKey)
- if (ascii >= 65) and (ascii <= 90) then
- enterLetter(me, ascii - 64)
- else
- if (ascii >= 97) and (ascii <= 122) then
- enterLetter(me, ascii - 96)
- else
- if ascii = 8 then
- eraseLetter(me)
- else
- if ascii = 45 then
- enterLetter(me, 53)
- end if
- end if
- end if
- end if
- end
-
- on anyAwards me
- if count(roadNameList) > 0 then
- set flag to 1
- end if
- repeat with boolean in awardsList
- if boolean = 1 then
- set flag to 1
- exit repeat
- end if
- end repeat
- return flag
- end
-
- on goMenu me, buttonObject
- addRoadName(me)
- clearAllActors()
- unpuppetAll()
- makeButtonJump(buttonObject)
- puppetPalette("AwardsPal")
- go("Grass")
- go(the frame + 1)
- unLoadCast()
- goLocationMap()
- end
-
- on returnToSim me, buttonObject
- addRoadName(me)
- clearAllActors()
- unpuppetAll()
- makeButtonJump(buttonObject)
- puppetPalette("AwardsPal")
- go("Grass")
- go(the frame + 1)
- puppetPalette("SimPal", 60)
- updateStage()
- puppetPalette(0)
- unLoadCast()
- set the status of gTruckObject to #idle
- set the programmedMove of gTruckObject to 0
- set the obstacleState of gSimObject to EMPTY
- go(label("Simulator" & string(the level of gLevelObject)))
- end
-
- on saveAwardsData me
- set awardsDataString to EMPTY
- if not anyAwards(me) then
- appendData(me, 0)
- else
- appendData(me, 1)
- set roadCount to count(roadNameList)
- appendData(me, roadCount)
- if roadCount > 0 then
- repeat with roadData in roadNameList
- set bitmapList to getAt(roadData, 1)
- appendData(me, count(bitmapList))
- repeat with bitmap in bitmapList
- appendData(me, bitmap)
- end repeat
- set offsetList to getAt(roadData, 2)
- appendData(me, count(offsetList))
- repeat with offset in offsetList
- appendData(me, offset)
- end repeat
- end repeat
- end if
- repeat with award in awardsList
- appendData(me, award)
- end repeat
- end if
- set awardsData to awardsDataString
- set awardsDataString to EMPTY
- return awardsData
- end
-
- on loadAwards me, index
- set dataCounter to index
- set anyAwards to readData(me)
- if anyAwards <> 0 then
- set howManyRoads to readData(me)
- if howManyRoads > 0 then
- repeat with x = 1 to howManyRoads
- set bitmapList to []
- set howManyBitmaps to readData(me)
- repeat with y = 1 to howManyBitmaps
- add(bitmapList, readData(me))
- end repeat
- set offsetList to []
- set howManyOffsets to readData(me)
- repeat with y = 1 to howManyOffsets
- add(offsetList, readData(me))
- end repeat
- add(roadNameList, [bitmapList, offsetList])
- end repeat
- end if
- repeat with x = 1 to count(awardsList)
- setAt(awardsList, x, readData(me))
- end repeat
- end if
- return dataCounter
- end
-
- on appendData me, datum
- set awardsDataString to awardsDataString & string(datum) & ","
- end
-
- on readData me
- set datum to value(item dataCounter of the dataString of gMenuObject)
- set dataCounter to dataCounter + 1
- return datum
- end
-
- on help me, buttonObject
- birth(script "Help Parent", buttonObject, #Awards)
- end
-